

#include <selectDrawingButton.h>
#include <renderer.h>
#include <input.h>
#include <drawingWidget.h>

SelectDrawingButton::SelectDrawingButton(){

textureID="icon_selectDrawing";
}


SelectDrawingButton::~SelectDrawingButton(){}


void SelectDrawingButton::setup(){
Button::setup();

}

void SelectDrawingButton::update(double deltaTime){}

void SelectDrawingButton::mouseOver(){

Button::mouseOver();
}

void SelectDrawingButton::mouseDrag(){}

void SelectDrawingButton::clickedLeft(){

input->focusButton=this;
}

void SelectDrawingButton::clickedRight(){}
void SelectDrawingButton::focusClick(){

Button::focusClick();

DrawingWidget *widge;
widge=(DrawingWidget*)parent;


if (dynamic_cast<ParticleSystem*>(input->worldTarget))
  {
   vector<Actor*>::iterator it;
      it=find(renderer->actorList.begin(),renderer->actorList.end(),input->worldTarget);
  widge->drawing=it-renderer->actorList.begin();

  cout << widge->drawing << endl;
  if (!DrawingWidget::brush)
    {
    DrawingWidget::brush = new Brush;
    DrawingWidget::brush->bPickable=false;
    DrawingWidget::brush->name="brush";
    DrawingWidget::brush->controller=input->controller;

    renderer->actorList.push_back(DrawingWidget::brush);
    cout << DrawingWidget::brush->name << endl;
    }
  DrawingWidget::brush->drawing=(ParticleSystem*)input->worldTarget;
  }

}

void SelectDrawingButton::deselect(int depth){

Button::deselect(depth);
}

void SelectDrawingButton::create(){renderer->addButton(this);}
